﻿using Harmontronics.DataAccess.IOperate.Business;
using Harmontronics.Model.Common;
using Harmontronics.Model.Dto.Model;
using Harmontronics.Model.Entitys;
using Harmontronics.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Harmontronics.DataAccess.Operate.Business
{
    public class RecipeConfigOperate : IRecipeConfigOperate
    {
        private HcDbContext _db { get; set; }
        public RecipeConfigOperate(HcDbContext db)
        {
            _db = db;
        }
        //查询所有
        public List<RecipeConfig> GetAllRecipeConfigList()
        {

            return _db.RecipeConfigs.ToList();
        }

        public RecipeConfig GetRecipeConfigById(string id)
        {
            return _db.RecipeConfigs.SingleOrDefault(i => i.ParameterId == id);
        }

        public List<RecipeConfig> GetRecipeConfigsByTypeId(string typeId) { 
            return _db.RecipeConfigs.Where(i => i.RecipeTypeId == typeId).ToList();
        }
        public List<RecipeConfig> GetRecipeConfigByIdList(List<string> ids)
        {
            return _db.RecipeConfigs.Where(i => ids.Contains(i.ParameterId)).ToList();
        }

        public void AddRecipeConfig(RecipeConfig entity)
        {
            _db.RecipeConfigs.Add(entity);
        }

        public void UpdateRecipeConfig(RecipeConfig entity)
        {
            _db.RecipeConfigs.Update(entity);
        }

        public void DeleteRecipeConfig(RecipeConfig entity)
        {
            _db.RecipeConfigs.Remove(entity);
        }

        public void BatchDelRecipeConfig(List<RecipeConfig> entity)
        {
            _db.RecipeConfigs.RemoveRange(entity);

        }
    }
}
